package CS331Lab3;

import junit.framework.TestCase;

public class TestDList extends TestCase {
	   public Integer i1 = new Integer(1);
	   public Integer i2 = new Integer(2);
	   public Integer i5 = new Integer(5);
	   public Integer i10 = new Integer(10);
	   public Integer i15 = new Integer(15);
	   public Integer i20 = new Integer(20);
	   public Integer i25 = new Integer(25);

	   public TestDList(String name) {
	      super(name);
	   }

	   public void testCreate() {
	      DList<Integer> d = new DList<Integer>();

	      assertEquals("1. Check Initial Size",0,d.size());
	      d.deleteFront();
	      assertEquals("2. Check Size After Delete On Empty", 0, d.size());
	      d.insertFront(i1);
	      assertEquals("3. Check Size Increment (Insert Front)", 1, d.size());
	      d.insertEnd(i2);
	      assertEquals("4. Check Size Increment (Insert End)", 2, d.size());
	      d.insertFront(i5);
	      d.insertEnd(i10);
	      assertEquals("5. Check Size after more inserts", 4, d.size());
	      DList<Integer>.makeFwdIterator iF1 = d.new makeFwdIterator();
	      assertEquals("6. Check Forward Iterator on First Element", i5, iF1.get());
	      assertEquals("7. Check Size After Get", 4, d.size());
	      DList<Integer>.makeRevIterator iR1 = d.new makeRevIterator();
	      assertEquals("8. Check Reverse Iterator on Last Element", i10, iR1.get());
	      iF1.next();
	      assertEquals("9. Check Forward Iterator on Second Element", i1, iF1.get());
	      iF1.next();
	      assertEquals("10. Check Forward Iterator on Third Element", i2, iF1.get());
	      iF1.next();
	      assertEquals("11. Check Forward Iterator on Last Element", i10, iF1.get());
	      iF1.next();
	      assertEquals("12. Check Forward Iterator Moving Past Last Element", null, iF1.get());
	      iR1.next();
	      assertEquals("13. Check Reverse Iterator on Second-to-Last Element", i2, iR1.get());
	      DList<Integer>.makeRevFindIterator iRF1 = d.new makeRevFindIterator();
	      assertEquals("14. Check Reverse Find Iterator on an Element not in the list", 0, iRF1.next(i25));
	      assertEquals("15. Check Reverse Find Iterator on an Element in the list", 1, iRF1.next(i2));
	      DList<Integer>.makeFwdFindIterator iFF1 = d.new makeFwdFindIterator();
	      assertEquals("16. Check Forward Find Iterator on an Element not in the list", 0, iFF1.next(i25));
	      assertEquals("17. Check Forward Find Iterator on an Element in the list", 1, iFF1.next(i2));
	      iR1.next();
	      assertEquals("18. Check Reverse Iterator on Third-to-Last Element", i1, iR1.get());
	      iR1.delete();
	      assertEquals("19. Check Size After Reverse Iterator Deletes Third-to-Last Element", 3, d.size());
	      assertEquals("20. Check Reverse Iterator Position After Delete", i2, iR1.get());
	      iR1.next();
	      assertEquals("21. Check Reverse Iterator On First Element", i5, iR1.get());
	      iR1.next();
	      assertEquals("22. Check Reverse Iterator After Moving Beyond First Element", null, iR1.get());
	   }
}
